package org.zjt.agent.generate;

import lombok.Getter;
import org.zjt.agent.generate.bytebuddy.ByteBuddyByteCodeGenerator;
import org.zjt.agent.generate.javassist.JavassistByteCodeGenerator;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

/**
 * Description:
 *
 * @author juntao.zhang
 * Date: 2018-07-05 下午2:29
 * @see
 */
@Getter
public enum  GeneratorEnum {

    BYTE_BUDDY("byteBuddy",ByteBuddyByteCodeGenerator.class),
    JAVASSIST("javassist",JavassistByteCodeGenerator.class);


    private final String name;

    private final Class clazz;


    GeneratorEnum(String name, Class clazz) {
        this.name = name;
        this.clazz = clazz;
    }


    public static Optional<GeneratorEnum> ofName(String name) {
        Optional<GeneratorEnum> first = Arrays.stream(GeneratorEnum.values()).filter(item -> Objects.equals(name, item.name)).findFirst();
        return first;
    }
}
